<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import="java.util.*" %>
<html>
<head>
	<title>session对象存储信息</title>
</head>
<body>

<br>输入姓名: <a href="session_15_a.jsp">输入姓名页面</a>
<br>选择图书：<a href="session_15_b.jsp">选择图书页面</a>
<br>结账：<a href="session_15_c.jsp">结账页面</a>

<hr>

<%!
	public String handleStr(String s){
		try{
			byte[] bb = s.getBytes("iso-8859-1");
			s = new String(bb);
		} catch(Exception exp){

		}
		return s;
	}
%>

<%
	//request.setCharacterEncoding("utf-8");
	String personName = (String) session.getAttribute("name");
	StringBuffer bookMess = null;
	if(personName==null || personName.length()==0){
		out.println("到输入名字页面");
	} else {
		bookMess = (StringBuffer)session.getAttribute("books");
	}
%>

<%
	String buyBook = "";
	try{
		buyBook = new String(bookMess);
	} catch(Exception e) {}
	
	double sum = 0;
	String[] price = buyBook.split("[^0123456789.]");
	if(price!=null){
		for(String item : price){
			try{
				sum += Double.parseDouble(item);
			} catch(NumberFormatException exp){

			}
		}
	}
%>

购书信息：<br>
<%= handleStr(buyBook) %><br>
总价格：<%= sum%><br>

</body>
</html>